<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="basePath" value="${pageContext.request.contextPath}"></c:set>
<%@ page import="com.linhai.scm.entity.base.User" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test User</title>
<script type="text/javascript" src="${basePath}/res/js/jquery_V1/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="${basePath}/res/om-ui/themes/elegant/om-all.css" />
</head>
<body>
表单
<input type="text" id="uname" />
<input type="text" id="uPwd" />
<a id="btn_Save" href="javascript:void(0)">保存</a>
<a id="btn_Auth" href="javascript:void(0)">验证</a>
<script type="text/javascript">
$(document).ready(function() {
	$('#btn_Save').omButton({
		onClick : function(event){
           save();
        }
	});
	$('#btn_Auth').omButton({
		onClick : function(event){
           auth();
        }
	});
});
function getData(){
	var uname=$("#uname").val();
	if(""==uname){
		alert("用户名不能为空！");
		$("#uname").focus();
		return null;
	}
	var uPwd=$("#uPwd").val();
	if(""==uPwd){
		alert("用户密码不能为空！");
		$("#uPwd").focus();
		return null;
	}
	//var data={uName:uname,uPwd:uPwd};//添加的
	//var data={id:8,uname:uname,uPwd:uPwd};//更新的
	//var data={id:800,uname:uname,uPwd:uPwd};//不存在的
	var data={"user.uname":uname,"user.upwd":uPwd};//使用对象模式提交，后台直接使用对象接收
	
	return data;
}
function submit(_url,_data){
	$.ajax({
		type: "POST",
		url: _url,
		data: _data,
		async: false,
		dataType: "json",
		success: function(data) {
			if(data.ok){
				alert("成功！\r\n"+data.msg);
			}else{
				alert("失败！\r\n"+data.msg);
			}
		}
	});
}
function save(){
	var data=getData();
	if(null==data){
		return null;
	}
	var url="User.h";
	submit(url,data);
}
function auth(){
	var data=getData();
	if(null==data){
		return null;
	}
	//var url="Client.h";
	var url="/testSSH/AddUser.action";
	submit(url,data);
}

</script>
<script type="text/javascript" src="${basePath}/res/om-ui/ui/om-core.js"></script>
<script type="text/javascript" src="${basePath}/res/om-ui/ui/om-button.js"></script>
</body>
</html>